package Tool;

import Javabean.User;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class MySQL_UserAdd {
    public static void  userAdd(Connection conn, User user) throws SQLException {
        //定义sql

        //查询

        String sql = "insert into staffsystem.user(ID,PassWord) values(?,?);";
        //获取执行psql的对象  PreparedStatement
        PreparedStatement pstmt = conn.prepareStatement(sql);

        //设置？的值
        pstmt.setString(1, user.getID());
        pstmt.setString(2, user.getPassWord());

        //执行sql语句
        pstmt.executeUpdate();

        //释放资源
        pstmt.close();
    }
}
